let db = require("../commons/db")
let JSONResponse = require("../commons/JSONResponse")

exports.listByUserId = (req, reps) => {
    let userId = req.session.user.id
    if (!userId) {
        reps.json(JSONResponse.fail("必须要有用户id"))
        return
    }
    db.query("select * from contact where user_id = ?", userId)
        .then(contants => {
            reps.json(JSONResponse.success(contants))
        })
}
exports.addContact = (req, resp) => {
    // let userId = req.session.user.id
    // let contactName = req.body.contactName
    // db.insert("insert into contact(user_id, contact_name) values(?, ?)", userId, contactName)
    //     .then(res => {
    //         resp.json(JSONResponse.success(null, 200, "添加联系人成功"))
    //     
    console.log("req", req.body)
}